#ifndef QNalogVNES_H
#define QNalogVNES_H

#include "qmybaseformwidget.h"
#include "ui_qNalogvnes.h"
#include <QStandardItemModel>
#include <QHeaderView>
#include "qstablewidgetdelegate.h"
#include "qcomboboxitemdelegate.h"
#include "chelperclass.h"

class QNalogVnes : public QMyBaseFormWidget
{
	Q_OBJECT

public:
	QNalogVnes(QWidget *parent = 0);
	~QNalogVnes();
	virtual void pressEscape();
	void setKomintent(QString text, QString textName);
	void setFocusLine();
	void setArtikli(QString text, QString textName);
	void setFocusLine2();
	void pressReturn();
	void pressF9();

private:

    typedef struct{
        QString aId;
        QString aSifra;
        QString aArtikal;
        QString aEdm;
        QString aKol;
        QString aKolMagArt;
        QString aInfo;
    } sostavInfo;

    bool eventFilter(QObject *object, QEvent *event);
	bool existDok(int idDok);
    void insertDetalMap(QString mId, QString keyString);
	Ui::QNalogVnesClass ui;
	QStandardItemModel *model;
	QStandardItemModel *model2;
    QHeaderView *header; 
    QHeaderView *header2; 
    int selRow;
    QString textId;
    QString komintentID;
    int artikal_id;
    QString dokumentID;
    QSTableWidgetDelegate *pItemDelegate;
    QModelIndex indexPrev;
    QModelIndex indexPrevTable2;
    bool editorOpen;
    QComboBoxItemDelegate *pComboItemDelegate;
    void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
	void lineEditPressReturn();
	bool validateKomintent();
    void lista_detail(const QString& nameSearch);
    
signals:
	void closeW();
	void scallKomintenti(QWidget*, QString);
	void scallArtikli(QWidget*, QString);
    void editCell();
    void closeCell();

	private slots:
        void on_pushButton_4_clicked();
		void on_pushButton_5_clicked();
		void on_pushButton_6_clicked();
		void on_pushButton_3_clicked();
		void on_pushButton_2_clicked();
		void on_pushButton_clicked();
		void selectionChanged(QModelIndex,QModelIndex);
        void selectionChangedDetail(QModelIndex modelX,QModelIndex modelY);
        void on_plineEdit3_Pressed();
        void on_plineEdit4_Pressed();
        void on_plineEdit5_Pressed();
        void openEditor();
        void closeEditor();
        void slotDoubleMC(const QModelIndex & ind);
        void updatePodatoci();
private:
    typedef std::vector<sostavInfo> tSostavInfo;
    std::map<QString, tSostavInfo> mListArtikli;

    QString m_selectedText;
    QModelIndex indexTable2;
    float m_vkkol;
    CHelperClass *m_chc;
};

#endif // QNalogVNES_H
